package com.bqtv.sport.commen.utils.countdown

import android.os.CountDownTimer

class CountDownUtils : CountDownTimer {
    private var listener: TickListener? = null

    /**
     * @param millisInFuture    The number of millis in the future from the call
     * to [.start] until the countdown is done and [.onFinish]
     * is called.
     * @param countDownInterval The interval along the way to receive
     * [.onTick] callbacks.
     */
    constructor(millisInFuture: Long, countDownInterval: Long) : super(
        millisInFuture,
        countDownInterval
    ) {
    }

    constructor(millisInFuture: Long, countDownInterval: Long, listener: TickListener?) : super(
        millisInFuture,
        countDownInterval
    ) {
        this.listener = listener
    }

    override fun onTick(millisUntilFinished: Long) {
        if (listener != null) {
            listener!!.tick(millisUntilFinished)
        }
    }

    override fun onFinish() {
        if (listener != null) {
            listener!!.done()
        }
    }
}